//package com.lyc.filter;

/**
 * 是否自动登录
 */
//@WebFilter(value = "/*",dispatcherTypes = {DispatcherType.ERROR,DispatcherType.FORWARD,DispatcherType.INCLUDE,DispatcherType.REQUEST})
//public class AutoLogin extends MyFilter {
//    private  UserService userService= new UserServiceImpl();
//    @Override
//    public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
//       //获得存放用户账户登录的session
//        HttpSession session = request.getSession();
//        User userAccount = (User) session.getAttribute("userAccount");
//        //如果当前是没有登录的状态，判断是否可以自动登录
//        String account ="";
//        String pwd="";
//        if (userAccount==null){
//              //获得存储账户和密码的cookie
//            Cookie[] cookies = request.getCookies();
//            for (Cookie cookie : cookies) {
//                if (cookie.equals("accountCookie")){
//                     account = cookie.getValue();
//                }
//                if (cookie.equals("pwdCookie")){
//                    pwd=cookie.getValue();
//                }
//            }
//            if (!("".equals(account))&&!("".equals(pwd))){
//                User user=new User();
//                user.setAccount(account);
//                user.setPwd(pwd);
//                User u = userService.accountLogin(user);
//                session.setAttribute("autoUserAccountLogin",u);
//            }
//        }
//        filterChain.doFilter(request,response);
//    }
//}
